package com.chehejia.devmng.platform.demo.demo1;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 描述:
 * 创建行
 * @author 王永坤
 * @createDate 2018-12-15 21:46
 */
public class Demo_sheet_row {
    public static void main(String[] args) {
        Workbook wb = new HSSFWorkbook();
        Sheet sheet = wb.createSheet("第一个sheet页面");
        Row row = sheet.createRow(0);//创建一个行
        Cell cell = row.createCell(0);//创建第一列
        cell.setCellValue(1);//给单元格设置值
        row.createCell(1).setCellValue(1.2);
        row.createCell(2).setCellValue("这是一个字符串");
        row.createCell(3).setCellValue(false);
        try  {
            FileOutputStream fileOutputStream = new FileOutputStream("D:\\第一次创建的Excel.xls");
            wb.write(fileOutputStream);
            fileOutputStream.flush();
            fileOutputStream.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {

        }

    }
}
